<?php
namespace app\learn\controller;

use app\BaseController;
use think\facade\View;
use function app\admin\controller\sum;
use function app\admin\controller\test;

class Other extends BaseController
{
    public function callAndApply()
    {
        //调用方法时...
        function test($name, $age, $address){
            return "我叫{$name}，我今年{$age}岁了，来自{$address}";
        }
        $param_list = ['赵海雷', 30, '山西省太原市'];
        dump(test(...$param_list));

        //定义方法时...
        function sum(...$nums){
            $sum = 0;
            foreach($nums as $num){
                $sum += $num;
            }
            return $sum;
        }
        dump(sum(18, 99, 37, 58, 64, 25));

        return View::fetch('other/call_and_apply');
    }
}
